*****************************************************************************************************

This folder contains example codes for the SPI Interface between the SD card and Blackfin processors.
The SPI implementation uses a subset of the SD Memory Card protocol and command set. The advantage of 
this mode is the capability of using an off-the-shelf host. The disadvantage is the loss of 
performance of the SPI mode versus SD mode (e.g. Single data line and hardware CS/ signal per card).
The SPI interface is selected during the first reset command after power up (CMD0) and cannot be 
changed once the part is powered on.

The SPI channel is byte oriented. Every command or data block is 8-bits long and is byte aligned 
to the CS/ signal (i.e. the length is a multiple of 8 clock cycles). The card starts to count SPI 
clock cycles at the assertion of CS/ signal. Every command or data token is aligned to the 8-clock 
cycle boundary. The SPI messages consist of command, response and data block tokens. 

The host starts every bus transaction by asserting the CS/ signal low. The selected card always 
responds to the command. When the card encounters a data retrieval problem in a read operation, 
it will respond with an error response (which replaces the expected data block). Additionally, 
every data block sent to the card during write operations will be responded with a data response 
token.

*****************************************************************************************************

EZ-KIT Lite Switch Setting:
1. Unpopulate JP3
2. SW9.4 = OFF
3. SW19.1, 3 = OFF
4. SW18.1,2 = OFF

*****************************************************************************************************

Algorithm for the code

1. After power up, drive SPISEL1/ inactive (logic high). This disables the card.
2. Issue at least 80 dummy clock cycles for the SD card initialization.
3. Drive SPISEL1/ low and transmit a CMD0 command. At this point, the card mode changes from the 
   default SD mode to SPI mode.
4. Wait for an R1 response from the card. The R1 response should be 0x01. Any other value indicates 
   an error condition. Re-execution starting from powering on may be required.
5. Issue a CMD1 command and wait for an R1 response. The R1 response should be 0x00. Any other response 
   value indicates of error condition.
6. After a correct R1 response for CMD1, data transfer can occur. Note that until the CMD1 command is 
   successful, the SPI baud rate (clock frequency) should be less than 400 kHz. Before data transfer 
   can begin, the SPI baud rate can be increased.
7. Commands such as set block length can now be issued.
8. Issue commands to read/write the SD card.
9. When powering off, check that the card is in the Ready state and drive SPISEL1/ high (inactive) 
   before turning off the power supplies. 

*****************************************************************************************************


